package data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PointList {
	private List<Point> list;

	public PointList() {
		this.list = new ArrayList<Point>();
	}

	public boolean add(Point p) {
		return list.add(p);
	}

	public void remove(Point p) {
		int index = list.indexOf(p);
		list.remove(index);
	}

	public boolean contains(Point p) {
		return list.contains(p);
	}

	public Point get(Point p) {
		int index = list.indexOf(p);
		return list.get(index);
	}

	public Point removeFirst() {
		return list.remove(0);
	}

	public int size() {
		return list.size();
	}

	public Point first() {
		if(list == null || list.size() == 0) {
			return null;
		}
		Collections.sort(list);
		return list.get(0);
	}

	@Override
	public String toString() {
		String result = "";
		for (Point p : list) {
			result += p.toString() + " ";
		}
		return result;
	}

	public List<Point> getList() {
		return list;
	}
}
